package com.sunyard.manage.controller;

import com.sunyard.dal.bo.token.TokenBO;
import com.sunyard.manage.service.RefreshTokenService;
import com.sunyard.utils.Response.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author 张昊坤
 * @Description token过期刷新
 * @Date 2021/3/8 14:40
 */

@Api(tags = "token过期刷新")
@Slf4j
@RestController
@RequestMapping(value = "/token", method = RequestMethod.POST)
@Validated
public class RefreshTokenController {

    @Autowired
    private RefreshTokenService refreshTokenService;

    @PostMapping("/refreshToken")
    @ResponseBody
    @ApiOperation("token过期刷新")
    public BaseResult refreshToken(@RequestBody TokenBO tokenBO, HttpServletResponse response, HttpServletRequest request) {
        return refreshTokenService.refreshToken(tokenBO, response, request);
    }


}
